package com.opennews.openplatform.dto.bank.card;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.opennews.openplatform.myspringbootcore.dto.IdentityDto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public abstract class BaseBankCardDto {
    @NotNull(message = "bank can't be null")
    private IdentityDto bank;

    @NotBlank(message = "name can't be blank")
    @Size(max = 50, message = "name must be at most 50 characters")
    private String name;

    @Size(max = 50, message = "statementDate must be at most 50 characters")
    private String statementDate;               // The example format: 15 means the 15th for each month.

    @Size(max = 50, message = "paymentDueDate must be at most 50 characters")
    private String paymentDueDate;              // The example format: +3  means 3rd of next month as statementDate. 24 means 24th of same private month as statementDate.

    @Size(max = 50, message = "customerServiceNumber must be at most 50 characters")
    private String customerServiceNumber;

    // IMPORTANT!!!
    // Without @JsonProperty("isCreditCard") you would find this field value will NOT be updated from request json data.
    // The issue occurs because the naming convention for boolean fields in Java, particularly when using libraries like Jackson,
    // can cause a mismatch between the JSON property and the generated getter/setter methods in your DTO.
    //
    // - In Java, a boolean field named isCreditCard generates a getter named isCreditCard() by default.
    // - However, Jackson maps the JSON property isCreditCard to the field by looking for a method named getIsCreditCard(),
    // which doesn't // exist. Instead, it treats the field as if it were unset and defaults to false.
    @JsonProperty("isCreditCard")
    private boolean isCreditCard;

    private boolean enabled;
}
